#include "logger.h"
#include <locale>
#include <codecvt>




void InitSpdlog(const std::string &logLevel, const std::string &fileName)
{
    spdlog::init_thread_pool(128, 1);

    auto stdout_sink = std::make_shared<spdlog::sinks::stdout_color_sink_mt>();
    stdout_sink->set_level(spdlog::level::trace);

    auto file_sink = std::make_shared<spdlog::sinks::daily_file_sink_mt>(fileName, 0, 0);
    file_sink->set_level(spdlog::level::info);
    
    std::vector<spdlog::sink_ptr> sinks{stdout_sink, file_sink};
    auto log = std::make_shared<spdlog::async_logger>("logger", sinks.begin(), sinks.end(),
                                                      spdlog::thread_pool(), spdlog::async_overflow_policy::block);
    
    log->set_level(spdlog::level::debug);
    log->set_pattern("[%Y-%m-%d %H:%M:%S.%e] [%^%l%$] [%s:%#] [%!] %v");
    log->flush_on(spdlog::level::debug);

    spdlog::set_default_logger(log);
    spdlog::flush_every(std::chrono::seconds(3));
}